<?

	$test = myopenconnection();

function myopenconnection()
{
//	if ($c=OCILogon("wtb", "serenco", "//192.168.1.250/xe")) 
	if ($c=oci_connect("wtb", "serenco", "//localhost/xe")) 
	{
		//echo "ket noi oracle ok";
  		return $c;
	}
	else
	{
		//echo "ket noi that bai";
		return "connect to oracle fails";
	}
		
}

function string2hex ( $string ) {
	  $hex = NULL;
	  for ( $ix=0; $ix < strlen($string); $ix=$ix+1 ) {
	    $char =  substr( $string, $ix, 1 );
	    $ord = ord ( $char );
	    if ( $ord < 16 ) {
	      $hex .= '0'.dechex( $ord );
	    }
	    else {
	      $hex .= dechex( $ord );
	    }
	    
	    // add line break or space
	    if ( $ix && ($ix % 16) == 15 ) {
	      $hex .= "\n";
	    }
	    else {
	      $hex .= "";
	    }
	  }
	  
	  // strip trailing space or linebreak
	  return  substr( $hex, 0, -1 );
	}
	
	function hex2string( $hex ) {
	  $string = NULL;
	  // strip linebreaks and spaces
	  $hex = str_replace( array("\n","\r"," "), "", $hex );
	  
	  for ( $ix=0; $ix < strlen($hex); $ix=$ix+2 ) {
	    $ord = hexdec( substr( $hex, $ix, 2 ) );
	    $string .= chr( $ord );
	  }
	  
	  return $string;
	}
	
	// convert an input string into it's binary equivalent.
	function asc2bin($inputString, $byteLength=8)
	{
		$binaryOutput = '';
		$strSize = strlen($inputString);
	
		for($x=0; $x<$strSize; $x++)
		{
			$charBin = decbin(ord($inputString{$x}));
			$charBin = str_pad($charBin, $byteLength, '0', STR_PAD_LEFT);
			$binaryOutput .= $charBin;
		}
	
		return $binaryOutput;
	}
	
	// convert a binary representation of a string back into it's original form.
	function bin2asc($binaryInput, $byteLength=8)
	{
		if (strlen($binaryInput) % $byteLength)
		{
			return false;
		}
		
		// why run strlen() so many times in a loop? Use of constants = speed increase.
		$strSize = strlen($binaryInput);
		$origStr = '';
	
		// jump between bytes.
		for($x=0; $x<$strSize; $x += $byteLength)
		{
			// extract character's binary code
			$charBinary = substr($binaryInput, $x, $byteLength);
			$origStr .= chr(bindec($charBinary)); // conversion to ASCII.
		}
		return $origStr;
	}

	function get_md5_unique_id(){ 
mt_srand ((double) microtime() * 1000000); 
return $unique_id = md5(uniqid(mt_rand(),1)); 
}// end get_md5_unique_id 

	function get_unique_id($length=32, $pool=""){ 
		// set pool of possible char 
		if($pool == ""){ 
		  $pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
		  $pool .= "abcdefghijklmnopqrstuvwxyz"; 
		  $pool .= "0123456789"; 
		}// end if 
		mt_srand ((double) microtime() * 1000000); 
		$unique_id = ""; 
		for ($index = 0; $index < $length; $index++) { 
		  $unique_id .= substr($pool, (mt_rand()%(strlen($pool))), 1); 
		}// end for 
		return(strtoupper($unique_id)); 
	}// end get_unique_id 
	
		function test($a) {
			return  $a;
	}
	
?>